package com.geekstudy.week9;

import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;

import java.util.EventListener;
import java.util.EventObject;

public class ListenerSubscriberAdapter implements Subscriber<EventObject> {

    private final EventListenerApi listener;

    public ListenerSubscriberAdapter(EventListenerApi listener) {
        this.listener = listener;
    }

    @Override
    public void onSubscribe(Subscription subscription) {
        subscription.request(Long.MAX_VALUE);
    }

    @Override
    public void onNext(EventObject eventObject) {
        listener.onEvent(eventObject);
    }

    @Override
    public void onError(Throwable throwable) {
        // TODO
    }

    @Override
    public void onComplete() {
        // TODO
    }
}
